<?php

namespace app\api\controller;
use app\common\controller\Api;
use think\Db;
use think\Exception;
use think\exception\PDOException;



class Shop extends Api
{

    // 无需登录的接口,*表示全部
    protected $noNeedLogin = ['test', 'test1'];
    // 无需鉴权的接口,*表示全部
    protected $noNeedRight = ['*'];


    //用户提交信息
    public function apply()
    {
        $uid = $this->auth->id;

        $data=$this->request->post();

        $data['user_id']=$uid;


        $user=Db::name('user')->where('id',$uid)->find();

        if (!$data['name']||!$data['zhizhaoimage']||!$data['zfsjimage']){
            $this->error('请填写必要信息');
        }

        $log=Db::name('merch')->where('user_id',$uid)->find();

        if($log){
            $this->error('您已申请过');
        }


        $data['admin_id']=$user['admin_id'];

        Db::name('merch')
            ->data($data)
            ->insert();

        $this->success('申请成功');




    }







}
